/* Name:        wx/wxPostgreSQL.h
 * Purpose:     connect to PostgreSQL database.
 * Sever version: 8.3
 * Author:      Trần Ngọc Quân
 * Modified by:
 * Created:     20/10/2010
 * RCS-ID:
 * Copyright:   (c) 2010-2011 wxPostgreSQL team
 * Licence: GPL
 */
#ifndef	WX_POSTGRESQL_H
#define WX_POSTGRESQL_H
#define WXPOSTGRESQL Pre-anpha //wxPostgreSQL version
#if !WX_PRECOMP
#include <wx/wx.h>
#else
// basic wxWidgets headers
#include <wx/wxprec.h>
#endif
#include <libpq-fe.h>
#include "wxpg_utils.h"

class wxPostgreSQLresult;

/** This is a object that keep connect to PostgreSQL*/
class wxPostgreSQL
{
public:
    /** Default contructor. This action will set conninfo="" */
    wxPostgreSQL(wxMBConv &_cnv);
    /** Copy contructor*/
    wxPostgreSQL(const wxPostgreSQL& pq, wxMBConv &_cnv);
    /**Contructor with connected string*/
    wxPostgreSQL(char* const constr,wxMBConv &_cnv);
    /**Contructor with connected wxString*/
    wxPostgreSQL(const wxString& constr,wxMBConv &_cnv);
    /**Connect with full parameter*/
    wxPostgreSQL(const char *pghost,
                 const char *pgport,
                 const char *pgoptions,
                 const char *pgtty,
                 const char *dbName,
                 const char *login,
                 const char *pwd, wxMBConv &_cnv);
    /** Make a connection to the database server in a nonblocking manner.*/
    wxPostgresPollingStatusType ConnectPoll();
    /** Close the current connection and free the data of wxPostgreSQL */
    void Finish();
    /**  Returns the default connection options. */
    static wxConninfoOption* ConnDefaults();
    /** free the data structure returned by ConnDefaults()*/
    void ConninfoFree();
    /** Reset the communication channel to the server, in a nonblocking manner. */
    int	ResetStart();
    /**Reset the communication channel to the server, in a nonblocking manner. */
    wxPostgresPollingStatusType ResetPoll();
    /** Synchronous (blocking) */
    void Reset();
    /** request a cancel structure */
    wxPGcancel* GetCancel();
    /** free a cancel structure */
    static void FreeCancel(wxPGcancel *cancel);
    /** issue a cancel request */
    static int	Cancel(wxPGcancel *cancel, char *errbuf, int errbufsize);
    /** backwards compatible version of Cancel; not thread-safe */
    int	RequestCancel();

 //   void cancelExecute();

    /* Accessor functions for PGconn objects */
    /** Returns the database name of the connection.*/
    char* GetDatabaseName();
    /**Returns the user name of the connection.*/
    char* GetUserName();
    /**Returns the password of the connection. */
    char* GetPassword();
    /**Returns the server host name of the connection. */
    char* GetHost();
    /**Returns the port of the connection. */
    char* GetPort();
    /**Returns the debug TTY of the connection. (This is obsolete, since the server no longer pays attention to the TTY setting, but the function remains for backwards compatibility.) */
    char* GetTTY();
    /** Returns the command-line options passed in the connection request. */
    char* Options();
    /**Returns the status of the connection. Value are: CONNECTION_OK, CONNECTION_BAD, CONNECTION_STARTED, CONNECTION_MADE, CONNECTION_AWAITING_RESPONSE, CONNECTION_AUTH_OK, CONNECTION_SETENV, CONNECTION_SSL_STARTUP, CONNECTION_NEEDED */
    wxConnStatusType Status();
    /**Returns the current in-transaction status of the server. Value are: PQTRANS_IDLE, PQTRANS_ACTIVE, PQTRANS_INTRANS, PQTRANS_INERROR, PQTRANS_UNKNOWN */
    wxPGTransactionStatusType TransactionStatus();
    /**Looks up a current parameter setting of the server. */
    const char* ParameterStatus(const char* paramName);
    /**Interrogates the frontend/backend protocol being used. */
    int	ProtocolVersion()const;
    /**Returns an integer representing the backend version. */
    int	ServerVersion()const;
    /**Returns the error message most recently generated by an operation on the connection. */
    char* ErrorMessage() const;
    /**Obtains the file descriptor number of the connection socket to the server. A valid descriptor will be greater than or equal to 0; a result of -1 indicates that no server connection is currently open. (This will not change during normal operation, but could change during connection setup or reset.) */
    int	Socket();
    /**Returns the process ID  (PID) of the backend server process handling this connection. */
    int	BackendPID();
    /**Returns true (1) if the connection authentication method used a caller-supplied password. Returns false (0) if not. */
    int	IsNeedsPassword();
    /**Returns true (1) if the connection authentication method used a caller-supplied password. Returns false (0) if not. */
    int	IsUsedPassword();
    /**Returns the client encoding. */
    int	GetClientEncoding();
    /**Sets the client encoding. */
    int	SetClientEncoding(const char *encoding);

    /** Get the OpenSSL structure associated with a connection. Returns NULL for
     * unencrypted connections or if any other TLS library is in use.*/
    void* GetSSL();

    /** Tell libpq whether it needs to initialize OpenSSL */
    static void InitSSL(int do_init);

    /** Set verbosity for ErrorMessage and ResultErrorMessage */
    wxVerbosity SetErrorVerbosity(wxVerbosity verbosity);

    /** Enable tracing */
    void Trace(FILE *debug_port);
    /** Disable tracing */
    void UnTrace();

    /* Override default notice handling routines */
    /** The function SetNoticeReceiver sets or examines the current notice receiver for a connection object.*/
    wxNoticeReceiver SetNoticeReceiver(wxNoticeReceiver proc, void *arg);
    /** SetNoticeProcessor sets or examines the current notice processor. */
    wxNoticeProcessor SetNoticeProcessor(wxNoticeProcessor proc, void *arg);
    /**a way to do cooperative locking between libpq and your application*/
    static pgthreadlock_t RegisterThreadLock(pgthreadlock_t newhandler);
    /**Submits a command to the server and waits for the result.*/
    wxPostgreSQLresult* Execute(const char *query);
    /**Submits a command to the server and waits for the result.*/
    wxPostgreSQLresult* Execute(const wxString& query);
    /** Submits a command to the server and waits for the result, with the ability to pass parameters separately from the SQL command text.*/
    wxPostgreSQLresult* ExecuteParams(const char *command,
                                      int nParams,
                                      const wxOid *paramTypes,
                                      const char *const * paramValues,
                                      const int *paramLengths,
                                      const int *paramFormats,
                                      int resultFormat);
    /** Submits a request to create a prepared statement with the given parameters, and waits for completion. */
    wxPostgreSQLresult* Prepare(const char *stmtName,
                                const char *query,
                                int nParams,
                                const wxOid *paramTypes);
    /** Sends a request to execute a prepared statement with given parameters, and waits for the result. */
    wxPostgreSQLresult* ExecutePrepared(const char *stmtName,
                                        int nParams,
                                        const char *const * paramValues,
                                        const int *paramLengths,
                                        const int *paramFormats,
                                        int resultFormat);

    /** Submits a command to the server without waiting for the result(s). 1 is returned if the command was successfully dispatched and 0 if not (in which case, use ErrorMessage to get more information about the failure). */
    int	SendQuery(const char *query);
    /** Submits a command and separate parameters to the server without waiting for the result(s).*/
    int SendQueryParams(const char *command,
                        int nParams,
                        const wxOid *paramTypes,
                        const char *const * paramValues,
                        const int *paramLengths,
                        const int *paramFormats,
                        int resultFormat);
    /** Sends a request to create a prepared statement with the given parameters, without waiting for completion. */
    int SendPrepare(const char *stmtName,
                    const char *query,
                    int nParams,
                    const Oid *paramTypes);
    /** Sends a request to execute a prepared statement with given parameters, without waiting for the result(s). */
    int SendQueryPrepared(const char *stmtName,
                          int nParams,
                          const char *const * paramValues,
                          const int *paramLengths,
                          const int *paramFormats,
                          int resultFormat);
    /**Waits for the next result from a prior SendQuery, SendQueryParams, SendPrepare, or SendQueryPrepared call, and returns it. A null pointer is returned when the command is complete and there will be no more results.*/
    wxPostgreSQLresult* GetResult();

    /** Returns 1 if a command is busy, that is, GetResult would block waiting for input. A 0 return indicates that GetResult can be called with assurance of not blocking.*/
    int	IsBusy();
    /** If input is available from the server, consume it. */
    int	ConsumeInput();

    /** The function Notifies  returns the next notification from a list of unhandled notification messages received from the server. It returns a null pointer if there are no pending notifications. Once a notification is returned from Notifies, it is considered handled and will be removed from the list of notifications. */
    wxPGnotify* Notifies();

    /** Sends data to the server during COPY_IN state. */
    int	PutCopyData(const char *buffer, int nbytes);
    /** Sends end-of-data indication to the server during COPY_IN state. */
    int	PutCopyEnd(const char *errormsg);

    /** Receives data from the server during COPY_OUT state. */
    int	GetCopyData(char **buffer, int async);
    /** Reads a newline-terminated line of characters (transmitted by the server) into a buffer string of size length. */
    int	Getline(char *string, int length);
    /**Sends a null-terminated string to the server. Returns 0 if OK and EOF if unable to send the string. */
    int	Putline(const char *string);
    /**Reads a row of COPY data (transmitted by the server) into a buffer without blocking. */
    int	GetlineAsync(char *buffer, int bufsize);
    /** Sends a non-null-terminated string to the server. Returns 0 if OK and EOF if unable to send the string. */
    int	PutnBytes(const char *buffer, int nbytes);
    /** Synchronizes with the server. */
    int	EndCopy();

    /** Sets the nonblocking status of the connection. */
    int	SetNonBlocking(int arg);
    /** Returns the blocking status of the database connection. */
    int	IsNonBlocking();
    /** Returns the thread safety status of the libpq library. */
    static int	IsThreadSafe();

    /** Attempts to flush any queued output data to the server. Returns 0 if successful (or if the send queue is empty), -1 if it failed for some reason, or 1 if it was unable to send all the data in the send queue yet (this case can only occur if the connection is nonblocking). */
    int	Flush();

    /** The function fn  requests execution of a server function via the fast-path interface: */
    wxPostgreSQLresult* fn(int fnid,
                           int *result_buf,
                           int *result_len,
                           int result_is_int,
                           const wxArgBlock *args,
                           int nargs);
    /** Submits a request to obtain information about the specified prepared statement, and waits for completion. */
    wxPostgreSQLresult* DescribePrepared(const char *stmt);
    /** Submits a request to obtain information about the specified portal, and waits for completion. */
    wxPostgreSQLresult* DescribePortal(const char *portal);
    /** Submits a request to obtain information about the specified prepared statement, without waiting for completion. */
    int	SendDescribePrepared(const char *stmt);
    /** Submits a request to obtain information about the specified portal, without waiting for completion. */
    int	SendDescribePortal(const char *portal);

    /**Frees memory allocated by libpq*/
    static void FreeMemory(void *ptr);

    /** Constructs an empty PGresult object with the given status. */
    wxPostgreSQLresult* MakeEmptyResult(ExecStatusType status);

    /** EscapeStringConn escapes a string for use within an SQL command. This is useful when inserting data values as literal constants in SQL commands. Certain characters (such as quotes and backslashes) must be escaped to prevent them from being interpreted specially by the SQL parser. EscapeStringConn performs this operation. */
    size_t EscapeStringConn(char *to, const char *from, size_t length, int *error);
    /** Escapes binary data for use within an SQL command with the type bytea. As with EscapeStringConn, this is only used when inserting data directly into an SQL command string. */
    unsigned char* EscapeByteaConn(const unsigned char *from, size_t from_length, size_t *to_length);
    /** EscapeBytea is an older, deprecated version of EscapeByteaConn. */
    static unsigned char* EscapeBytea(const unsigned char *from, size_t from_length, size_t *to_length);
    /** Converts a string representation of binary data into binary data — the reverse of EscapeBytea. This is needed when retrieving bytea data in text format, but not when retrieving it in binary format. */
    unsigned char* UnescapeBytea(const unsigned char *strtext, size_t *retbuflen);

    /**EscapeStringConn returns the number of bytes written to to, not including the terminating zero byte. */
    static size_t EscapeString(char *to, const char *from, size_t length);

    /* === in fe-lobj.c === */
    /* Large-object access routines */
    /** To open an existing large object for reading or writing, call */
    int	lo_open(wxOid lobjId, int mode);
    /** A large object descriptor can be closed by calling */
    int	lo_close(int fd);
    /**  reads len bytes from large object descriptor fd into buf. The fd argument must have been returned by a previous lo_open. The number of bytes actually read is returned. In the event of an error, the return value is negative.*/
    int	lo_read(int fd, char *buf, size_t len);
    /**  writes len bytes from buf  to large object descriptor fd. The fd  argument must have been returned by a previous lo_open. The number of bytes actually written is returned. In the event of an error, the return value is negative.*/
    int	lo_write(int fd, const char *buf, size_t len);
    /**  This function moves the current location pointer for the large object descriptor identified by fd to the new location specified by offset. The valid values for whence  are SEEK_SET (seek from object start), SEEK_CUR (seek from current position), and SEEK_END (seek from object end). The return value is the new location pointer, or -1 on error.*/
    int	lo_lseek(int fd, int offset, int whence);
    /**  creates a new large object. The return value is the OID that was assigned to the new large object, or InvalidOid (zero) on failure. mode is unused and ignored as of PostgreSQL 8.1; however, for backwards compatibility with earlier releases it is best to set it to INV_READ, INV_WRITE, or INV_READ | INV_WRITE. (These symbolic constants are defined in the header file libpq/libpq-fs.h.) */
    wxOid lo_creat(int mode);
    /**  also creates a new large object. The OID to be assigned can be specified by lobjId; if so, failure occurs if that OID is already in use for some large object. If lobjId  is InvalidOid (zero) then lo_create assigns an unused OID (this is the same behavior as lo_creat). The return value is the OID that was assigned to the new large object, or InvalidOid (zero) on failure. */
    wxOid lo_create(wxOid lobjId);
    /** To obtain the current read or write location of a large object descriptor, call */
    int	lo_tell(int fd);
    /**  truncates the large object descriptor fd to length len. The fd argument must have been returned by a previous lo_open. If len is greater than the current large object length, the large object is extended with null bytes ('\0').*/
    int	lo_truncate(int fd, size_t len);
    /** To remove a large object from the database, call */
    int	lo_unlink(wxOid lobjId);
    /** To import an operating system file as a large object, call */
    wxOid lo_import(const char *filename);
    /** To export a large object into an operating system file, call */
    int	lo_export(wxOid lobjId, const char *filename);

    wxString ExecuteScalar(const wxString &sql);
    bool ExecuteVoid(const wxString &sql);

    /* === in fe-misc.c === */
    /** Determine length of multibyte encoded char at *s */
    static int	mblen(const char *s, int encoding);

    /** Determine display length of multibyte encoded char at *s */
    static int	dsplen(const char *s, int encoding);

    /** Get encoding id from environment variable PGCLIENTENCODING */
    static int	env2encoding();

    /* === in fe-auth.c === */
	/**Prepares the encrypted form of a PostgreSQL password. */
    static char* EncryptPassword(const char *passwd, const char *user);

    /* === in encnames.c === */

    /**Return encoding from name in string format*/
    static int	char2encoding(const char *name);
    /**Return name of encoding*/
    static const char* encoding2char(int encoding);
    /**Check if encoding is valid from server*/
    static int	valid_server_encoding_id(int encoding);
    /**Default Destructor*/
    ~wxPostgreSQL();
//    void SetConnCancel(void);
//	void ResetConnCancel(void);
    void Close();
	bool Reconnect();

	wxPGconn * get_conn()
	{
	    return this->conn;
	}

	bool isneedColQuoting()
	{
	    return needColQuoting;
	}

    bool IsAlive();

    int GetStatus()
    {
        return connstatus;
    }

protected:

    int lastResultStatus;
    int connstatus;

    wxPGconn* conn;
    wxMBConv *conv;
 //   PGcancel *m_cancelConn;
//	wxMutex   m_cancelConnMutex;
	bool needColQuoting;


private:

    char* conninfo;
    wxConninfoOption* connOptions;


};
//End of declaration wxPostgreSQL class

/** Contain result that return from wxPostgreSQL Query or Command*/
class wxPostgreSQLresult
{
public:
    /**Default constructor*/
    wxPostgreSQLresult();
    /**Constructor from an result*/
    wxPostgreSQLresult(wxResult* newres, wxPostgreSQL *newconn, wxMBConv &cnv, bool needColQt);
    /**Default destructor*/
    ~wxPostgreSQLresult();
    /** Returns the result status of the command. Value are: PGRES_EMPTY_QUERY = 0, PGRES_COMMAND_OK, PGRES_TUPLES_OK, PGRES_COPY_OUT, PGRES_COPY_IN, PGRES_BAD_RESPONSE, PGRES_NONFATAL_ERROR, PGRES_FATAL_ERROR */
    wxExecStatusType Status();
    /** Frees the storage associated with a wxPostgreSQLresult. Every command result should be freed via Clear() when it is no longer needed. */
    void Clear();
    /** Converts the enumerated type returned by ResultStatus into a string constant describing the status code. The caller should not free the result. */
    char* StatusMessage(wxExecStatusType status);
    /** Returns the error message associated with the command, or an empty string if there was no error. */
    char* ErrorMessage();
    /** Returns an individual field of an error report. */
    char* ErrorFieldMessage(int fieldcode);
    /** Returns the number of rows (tuples) in the query result. Because it returns an integer result, large result sets might overflow the return value on 32-bit operating systems. */
    int	GetRowsNumber();
    /** Returns the number of columns (fields) in each row of the query result. */
    int	GetNumberFields();
    /** Returns 1 if the wxPostgreSQLresult contains binary data and 0 if it contains text data. */
    int	IsBinary();
    /** Returns the column name associated with the given column number. Column numbers start at 0. The caller should not free the result directly. It will be freed when the associated wxPostgreSQLresult handle is passed to Clear. */
    char* FieldName(int field_num);
    /** Returns the column number associated with the given column name. */
    int	FieldNumber(const char *field_name);
    /** Returns the wxOID of the table from which the given column was fetched. Column numbers start at 0. */
    wxOid FieldTable(int field_num);
    /** Returns the column number (within its table) of the column making up the specified query result column. Query-result column numbers start at 0, but table columns have nonzero numbers. */
    int	FieldTableColumn(int field_num);
    /** Returns the format code indicating the format of the given column. Column numbers start at 0. */
    int	FieldFormat(int field_num);
    /** Returns the data type associated with the given column number. The integer returned is the internal OID number of the type. Column numbers start at 0. */
    wxOid FieldType(int field_num);
    /** Returns the size in bytes of the column associated with the given column number. Column numbers start at 0. */
    int	FieldSize(int field_num);
    /** Returns the type modifier of the column associated with the given column number. Column numbers start at 0. */
    int	FieldModifier(int field_num);
    /** Returns the command status tag from the SQL command that generated the PGresult. */
    char* CommandStatus();
    /** Returns a string with the OID of the inserted row, if the SQL command was an INSERT  that inserted exactly one row, or a EXECUTE of a prepared statement consisting of a suitable INSERT. (The string will be 0 if the INSERT did not insert exactly one row, or if the target table does not have OIDs.) If the command was not an INSERT, returns an empty string. */
    char* OidStatus();	/* old and ugly */
    /** Returns the OID  of the inserted row, if the SQL command was an INSERT that inserted exactly one row into a table that has OIDs, or a EXECUTE of a prepared query containing a suitable INSERT statement. Otherwise, this function returns InvalidOid. This function will also return InvalidOid if the table affected by the INSERT statement does not contain OIDs. */
    wxOid OidValue();	/* new and improved */
    /** Returns the number of rows affected by the SQL command. */
    char* CommandNumberRows();
    /** Returns a single field value of one row of a PGresult. Row and column numbers start at 0. The caller should not free the result directly. It will be freed when the associated wxPostgreSQLresult handle is passed to Clear. */
    char* GetValue(int tup_num, int field_num);
    /** Returns the actual length of a field value in bytes. Row and column numbers start at 0. */
    int	GetLength(int tup_num, int field_num);
    /** Tests a field for a null value. Row and column numbers start at 0. */
    int	IsNull(int tup_num, int field_num);
    /** Returns the number of parameters of a prepared statement. */
    int	NumberParams();
    /** Returns the data type of the indicated statement parameter. Parameter numbers start at 0. */
    wxOid ParamType(int param_num);
	/**Prints out all the rows and, optionally, the column names to the specified output stream*/
    void Print(FILE *fout, /* output stream */
               const wxPrintOpt *ps);	/* option structure */
    /** really old printing routines */
    void DisplayRows(FILE *fp,		/* where to send the output */
                     int fillAlign,	/* pad the fields with spaces */
                     const char *fieldSep,	/* field separator */
                     int printHeader,	/* display headers? */
                     int quiet);

	/**Prints out all the rows to the specified output stream with custom format*/
    void PrintRows(FILE *fout,		/* output stream */
                   int printAttName, /* print attribute names */
                   int terseOutput,	/* delimiter bars */
                   int width);		/* width of column, if 0, use variable width */

//plugins added by mikewolfli
	long NumRows() const
	{
		return nRows;
	}
	long NumCols() const
	{
		return nCols;
	}

	void MoveNext()
	{
		if (pos <= nRows) pos++;
	}
	void MovePrevious()
	{
		if (pos > 0) pos--;
	}
	void MoveFirst()
	{
		if (nRows) pos = 1;
		else pos = 0;
	}
	void MoveLast()
	{
		pos = nRows;
	}
	void Locate(long l)
	{
		pos = l;
	}
	long CurrentPos() const
	{
		return pos;
	}
	bool Bof() const
	{
		return (!nRows || pos < 1);
	}
	bool Eof() const
	{
		return (!nRows || pos > nRows);
	}
	wxString ColName(const int col) const;
	wxOid ColTypeOID(const int col) const;
	long ColTypeMod(const int col) const;
	wxString ColType(const int col) const;
	wxString ColFullType(const int col) const;
	pgTypClass ColTypClass(const int col) const;

	wxOid GetInsertedOid() const
	{
		return ::PQoidValue(this->res);
	}
	long GetInsertedCount() const;
	int ColSize(const int col) const
	{
		return  ::PQfsize(this->res, col);
	}
	bool IsNull(const int col) const
	{
		return (::PQgetisnull(this->res, pos - 1, col) != 0);
	}
	int ColScale(const int col) const;
	int ColNumber(const wxString &colName) const;
	bool HasColumn(const wxString &colname) const;


	wxString GetVal(const int col) const;
	wxString GetVal(const wxString &col) const;
	long GetLong(const int col) const;
	long GetLong(const wxString &col) const;
	int GetInt(const int col) const;
	int GetInt(const wxString &col) const;
	bool GetBool(const int col) const;
	bool GetBool(const wxString &col) const;
	double GetDouble(const int col) const;
	double GetDouble(const wxString &col) const;
	wxDateTime GetDateTime(const int col) const;
	wxDateTime GetDateTime(const wxString &col) const;
	wxDateTime GetDate(const int col) const;
	wxDateTime GetDate(const wxString &col) const;
	wxULongLong GetLongLong(const int col) const;
	wxULongLong GetLongLong(const wxString &col) const;
	wxOid GetOid(const int col) const;
	wxOid GetOid(const wxString &col) const;

	char *GetCharPtr(const int col) const;
	char *GetCharPtr(const wxString &col) const;

	wxMBConv &GetConversion() const
	{
		return conv;
	}

	wxString GetCommandStatus() const
	{
		if (res)
		{
			return wxString(::PQcmdStatus(this->res), conv);
		}
		return wxEmptyString;
	}
	//plugins added by mikewolfli
protected:

private:
    wxResult* res;
    wxPostgreSQL *conn;

    //plugins added by mikewolfli
	long pos, nRows, nCols;
	wxString ExecuteScalar(const wxString &sql) const;
	wxMBConv &conv;
	bool needColQuoting;
	mutable wxArrayString colTypes, colFullTypes;
	wxArrayInt colClasses;
    //plugins added by mikewolfli
};


class wxPgResultIterator
{
public:
	wxPgResultIterator(wxPostgreSQLresult *s);
	wxPgResultIterator(wxPostgreSQL *conn, const wxString &sql);
	~wxPgResultIterator();

	bool RowsLeft();
	bool MovePrev();
	bool IsValid()
	{
		return set != 0;
	}
	wxPostgreSQLresult *Set()
	{
		return set;
	}

	wxString GetVal(const int col) const
	{
		return set->GetVal(col);
	}
	wxString GetVal(const wxString &col) const
	{
		return set->GetVal(col);
	}
	long GetLong(const int col) const
	{
		return set->GetLong(col);
	}
	long GetLong(const wxString &col) const
	{
		return set->GetLong(col);
	}
	bool GetBool(const int col) const
	{
		return set->GetBool(col);
	}
	bool GetBool(const wxString &col) const
	{
		return set->GetBool(col);
	}
	double GetDouble(const int col) const
	{
		return set->GetDouble(col);
	}
	double GetDouble(const wxString &col) const
	{
		return set->GetDouble(col);
	}
	wxDateTime GetDateTime(const int col) const
	{
		return set->GetDateTime(col);
	}
	wxDateTime GetDateTime(const wxString &col) const
	{
		return set->GetDateTime(col);
	}
	wxDateTime GetDate(const int col) const
	{
		return set->GetDate(col);
	}
	wxDateTime GetDate(const wxString &col) const
	{
		return set->GetDate(col);
	}
	wxULongLong GetLongLong(const int col) const
	{
		return set->GetLongLong(col);
	}
	wxULongLong GetLongLong(const wxString &col) const
	{
		return set->GetLongLong(col);
	}
	wxOid GetOid(const int col) const
	{
		return set->GetOid(col);
	}
	wxOid GetOid(const wxString &col) const
	{
		return set->GetOid(col);
	}

protected:
	wxPostgreSQLresult *set;
	bool first;
};


#endif // End wxPostgreSQL.h


